/*
门店管理
*/
<template>
  <div class="app-page">
    <!-- 操作菜单区 -->
    <my-header>
      <el-button type="primary" @click="handleAddUpdate()" v-repeatClick
      >添加门店
      </el-button
      >
      <el-button @click="handleBeforeUpdate" v-repeatClick>修改</el-button>
      <!-- <el-button>上移</el-button>
      <el-button>下移</el-button> -->
      <el-button @click="enabled(false)">禁用</el-button>
      <el-button @click="enabled(true)">启用</el-button>
      <el-button @click="storeView" v-repeatClick>查看</el-button>
      <el-button @click="getStores" v-repeatClick>刷新</el-button>
      <el-button type="danger" @click="delStores" v-repeatClick>删除</el-button>
    </my-header>

    <!-- 列表区 -->
    <div style="flex: 1; margin-bottom: 10px">
      <div style="display: flex" class="content-height">
        <el-card style="width: 250px">
          <div style="margin-bottom: 10px">所属国家</div>
          <el-tree
            :data="treeData"
            highlight-current
            @node-click="handleNodeClick"
          ></el-tree>
        </el-card>
        <el-card style="flex: 1; margin-left: 10px">
          <div class="app-page">
            <!-- 搜索区 -->
            <div class="content-flex">
              <div>
                <el-form ref="search" :model="search" inline size="small">
                  <el-form-item label="" prop="name">
                    <el-input
                      placeholder="搜索:门店名称"
                      v-model="search.name"
                      clearable
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="" prop="Enabled">
                    <el-select
                      clearable
                      v-model="search.Enabled"
                      placeholder="是否启用"
                      style="width: 100px"
                    >
                      <el-option label="是" :value="true"></el-option>
                      <el-option label="否" :value="false"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="" prop="query_batchId">
                    <el-button type="primary" round @click="searchPage"
                    >搜索
                    </el-button
                    >
                    <el-button
                      type="warning"
                      round
                      @click="$refs.search.resetFields()"
                    >重置
                    </el-button
                    >
                  </el-form-item>
                </el-form>
              </div>
              <div style="margin-bottom: 10px;min-width: 100px;text-align: right" class="storeColor">
                <el-button
                  type="text"
                  v-if="selectCountry"
                  style="font-size: 14px"
                >{{ selectCountry }}
                </el-button
                >
                <span v-else>全部门店</span>
              </div>
            </div>
            <!-- 列表区 -->
            <div style="flex: 1">
              <el-table
                height="100%"
                :data="data"
                border
                stripe
                highlight-current-row
                ref="multipleTable"
                @row-dblclick="handleRowDbclick"
                @selection-change="handleSelectionChange"
              >
                <el-table-column type="index" width="55" align="center">
                </el-table-column>
                <el-table-column type="selection" width="55" align="center">
                </el-table-column>
                <el-table-column label="门店名称">
                  <template slot-scope="scope">
                    <div class="tdItem">
                      <el-link @click="handleRowDbclick(scope.row)"
                      >{{ scope.row.name }}({{ scope.row.code }})
                      </el-link
                      >
                    </div>
                    <div class="tdItem">
                      {{ scope.row.currencyType }}({{
                        scope.row.currencySymbol
                      }})
                    </div>
                    <div class="tdItem">
                      {{ scope.row.weightUnit }}({{
                        scope.row.weightUnit == '公斤' ? 'kg' : 'lbs'
                      }})
                    </div>
                  </template>
                </el-table-column>
                <el-table-column label="联系方式和地址">
                  <template slot-scope="scope">
                    <div class="tdItem">
                      {{
                        scope.row.countryName +
                        scope.row.provinceName +
                        scope.row.cityName +
                        scope.row.countyName +
                        scope.row.streetName
                      }}
                    </div>
                    <div class="tdItem">
                      {{
                        scope.row.address
                      }}<span
                      style="margin-left: 5px"
                      v-if="scope.row.postalCode"
                    >{{ scope.row.postalCode }}</span
                    >
                    </div>
                    <div class="tdItem">{{ scope.row.phoneNum }}</div>
                    <div class="tdItem">{{ scope.row.mobilePhoneNum }}</div>
                    <div class="tdItem">{{ scope.row.email }}</div>
                  </template>
                </el-table-column>
                <el-table-column label="启用" align="center" width="100">
                  <template slot-scope="scope">
                    <span style="font-size: 20px">
                      <i
                        class="el-icon-circle-check"
                        style="color: #67c23a"
                        v-if="scope.row.enabled"
                      ></i>
                      <i
                        class="el-icon-circle-close"
                        style="color: #f56c6c"
                        v-else
                      ></i>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  label="创建时间"
                  sortable
                  prop="createTime"
                  align="center"
                ></el-table-column>
              </el-table>
            </div>
            <!-- 分页区 -->
            <div style="margin-top: 10px">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[20, 50, 100, 200, 500, 1000]"
                :page-size="pageSize"
                background
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
              >
              </el-pagination>
            </div>
          </div>
        </el-card>
      </div>
    </div>

    <!-- 添加修改门店信息 -->
    <el-dialog
      :title="title + '门店'"
      v-dialog-drag
      :visible.sync="dialogFormVisible"
      :close-on-click-modal="false"
      @close="restForm"
    >
      <div style="position: relative">
        <el-tabs v-model="activeName" type="card">
          <el-tab-pane label="门店信息" name="storeBaseForm">
            <el-form
              size="small"
              :model="storeBaseForm"
              label-position="left"
              label-width="120px"
              ref="storeBaseForm"
              :rules="storeBaseRules"
            >
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="name" label="门店名称">
                    <el-input v-model="storeBaseForm.name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="code" label="门店编码">
                    <el-input v-model="storeBaseForm.code"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="outCycle" label="出店周期">
                    <el-select
                      style="width: 100%"
                      placeholder="请选择出店周期"
                      multiple
                      v-model="storeBaseForm.outCycle"
                    >
                      <el-option
                        v-for="item in [
                          '星期一',
                          '星期二',
                          '星期三',
                          '星期四',
                          '星期五',
                          '星期六',
                          '星期日',
                        ]"
                        :key="item"
                        :label="item"
                        :value="item"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="weightUnit" label="重量单位">
                    <el-select
                      style="width: 100%"
                      placeholder="请选择重量单位"
                      v-model="storeBaseForm.weightUnit"
                    >
                      <el-option
                        v-for="item in storeBaseOptions.weightUnit"
                        :key="item.content"
                        :label="item.content"
                        :value="item.content"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="currencyType" label="货币单位">
                    <el-select
                      style="width: 100%"
                      placeholder="请选择货币单位"
                      v-model="storeBaseForm.currencyType"
                    >
                      <el-option
                        v-for="item in storeBaseOptions.currencyType"
                        :key="item.content"
                        :label="item.content"
                        :value="item.content"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="currencySymbol" label="货币符号">
                    <el-select
                      style="width: 100%"
                      placeholder="请选择货币符号"
                      v-model="storeBaseForm.currencySymbol"
                    >
                      <el-option
                        v-for="item in storeBaseOptions.currencySymbol"
                        :key="item.content"
                        :label="item.content"
                        :value="item.content"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="orderPrefix" label="运单号前缀">
                    <el-input v-model="storeBaseForm.orderPrefix"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="orderSubfix" label="运单号后缀">
                    <el-input v-model="storeBaseForm.orderSubfix"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="详细信息" name="storeDetailForm">
            <el-form
              size="small"
              :model="storeDetailForm"
              label-position="left"
              label-width="120px"
              ref="storeDetailForm"
              :rules="storeDetailRules"
            >
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="countryName" label="国家名称">
                    <el-select
                      @change="handleCountryChange"
                      filterable
                      style="width: 100%"
                      v-model="storeDetailForm.countryName"
                      placeholder="请选择国家名称"
                    >
                      <el-option
                        v-for="item in storeDetailOptions.countryName"
                        :key="item"
                        :value="item"
                        :label="item"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="provinceName" label="省份名称">
                    <el-select
                      filterable
                      @change="handleProvinceChange"
                      style="width: 100%"
                      v-model="storeDetailForm.provinceName"
                      placeholder="请选择省份名称"
                    >
                      <el-option
                        v-for="item in storeDetailOptions.provinceName"
                        :key="item"
                        :value="item"
                        :label="item"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="cityName" label="城市名称">
                    <el-select
                      filterable
                      style="width: 100%"
                      v-model="storeDetailForm.cityName"
                      placeholder="请选择城市名称"
                    >
                      <el-option
                        v-for="item in storeDetailOptions.cityName"
                        :key="item"
                        :value="item"
                        :label="item"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="countyName" label="区县名称">
                    <el-input
                      v-model="storeDetailForm.countyName"
                    ></el-input>
                    <!-- <el-select
                      placeholder="请选择区县名称"
                      style="width: 100%"
                      filterable
                      v-model="storeDetailForm.countyName"
                    >
                      <el-option
                        v-for="item in storeDetailOptions.countyName"
                        :key="item"
                        :value="item"
                        :label="item"
                      ></el-option>
                    </el-select> -->
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="streetName" label="街道名称">
                    <el-input
                      v-model="storeDetailForm.streetName"
                    ></el-input>
                    <!-- <el-select
                      style="width: 100%"
                      v-model="storeDetailForm.streetName"
                    >
                      <el-option
                        v-for="item in storeDetailOptions.streetName"
                        :key="item"
                        :value="item"
                        :label="item"
                      ></el-option>
                    </el-select> -->
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="address" label="详细地址">
                    <el-input
                      v-model="storeDetailForm.address"
                      type="textarea"
                      autosize
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="postalCode" label="邮政编码">
                    <el-input
                      v-model="storeDetailForm.postalCode"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="phoneNum" label="电话">
                    <el-input
                      v-model="storeDetailForm.phoneNum"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="mobilePhoneNum" label="手机">
                    <el-input
                      v-model="storeDetailForm.mobilePhoneNum"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="faxNum" label="传真">
                    <el-input v-model="storeDetailForm.faxNum"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <el-form-item prop="email" label="电子邮件">
                    <el-input v-model="storeDetailForm.email"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="note" label="备注信息">
                    <el-input v-model="storeDetailForm.note"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="运单收费项目" name="waybillForm">
            <el-card>
              <el-table :data="waybillInfos" border>
                <el-table-column label="操作" align="center" width="80">
                  <template slot-scope="scope">
                    <el-button
                      type="danger"
                      circle
                      icon="el-icon-close"
                      @click="deletewaybill(scope.$index)"
                    ></el-button>
                  </template>
                </el-table-column>
                <el-table-column label="项目类型">
                  <template slot-scope="scope">
                    <el-select v-model="scope.row.type">
                      <el-option label="包装类" value="包装类"></el-option>
                      <el-option label="服务类" value="服务类"></el-option>
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column label="收费项目名称">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.name"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="收费项目金额">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.amount"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="修改人"
                  prop="updateUser"
                ></el-table-column>
                <el-table-column
                  label="修改时间"
                  prop="updateTime"
                ></el-table-column>
              </el-table>
              <div style="text-align: right; margin-top: 10px">
                <el-link type="primary" :underline="false" @click="addwaybill">
                  <el-button icon="el-icon-plus" type="primary" circle>
                  </el-button>
                  添加运单收费项目
                </el-link>
              </div>
            </el-card>
          </el-tab-pane>
        </el-tabs>
        <div style="position: absolute; top: 5px; right: 0">
          <el-link
            type="primary"
            icon="el-icon-s-home"
            v-if="title=='修改'"
            disabled
            style="margin-right: 10px; font-size: 16px"
          >{{ this.storeBaseForm.name }}
          </el-link
          >
          <el-checkbox v-model="storeBaseForm.enabled">启用</el-checkbox>
          <el-button
            type="primary"
            style="margin-left: 10px"
            @click="submit"
            v-repeatClick
          ><i class="fa fa-floppy-o" style="margin-right: 10px"></i
          >保存设置
          </el-button
          >
        </div>
      </div>
    </el-dialog>
    <!-- 查看门店信息 -->
    <el-dialog title="查看门店" :visible.sync="dialogViewVisible" :close-on-click-modal="false" v-dialog-drag>
      <el-tabs type="card">
        <el-tab-pane
          v-for="item in multipleSelection"
          :key="item.id"
          :label="item.name"
        >
          <el-form>
            <el-col :span="12">
              <el-form-item label="门店名称：">{{ item.name }}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="门店编码：">{{ item.code }}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="启用：">{{
                  item.enabled ? '是' : '否'
                }}
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="电话：">{{ item.phoneNum }}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="手机：">{{
                  item.mobilePhoneNum
                }}
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="地址：">{{ item.address }}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="电子邮件：">{{ item.email }}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="传真：">{{ item.faxNum }}</el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="备注：">{{ item.note }}</el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="创建人：">{{
                  item.createUser
                }}
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="创建时间">{{
                  item.createTime
                }}
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="修改人：">{{
                  item.updateUser
                }}
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="修改时间">{{
                  item.updateTime
                }}
              </el-form-item>
            </el-col>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
  </div>
</template>

<script>
let search = {
  //门店名称
  name: '',
  //是否启用
  Enabled: ''
}

//门店基本信息表单
let storeBaseForm = {
  //门店名称
  name: '',
  //门店编码
  code: '',
  //出店周期
  outCycle: '',
  //货币单位
  currencyType: '',
  //货币符号
  currencySymbol: '',
  //重量单位
  weightUnit: '',
  //运单号前缀
  orderPrefix: '',
  //运单号后缀
  orderSubfix: '',
  //是否启用
  enabled: true
}
//门店详细信息表单
let storeDetailForm = {
  //国家名称
  countryName: '',
  //省份
  provinceName: '',
  //城市名称
  cityName: '',
  //县
  countyName: '',
  //街道
  streetName: '',
  //邮政编码
  postalCode: '',
  //详细地址
  address: '',
  //电话
  phoneNum: '',
  //手机
  mobilePhoneNum: '',
  //传真
  faxNum: '',
  //电子邮件
  email: '',
  //备注信息
  note: ''
}
//运单收费表单
let waybillForm = {
  //项目类型
  type: '包装类',
  //收费项目名称
  name: '',
  //收费项目金额
  amount: ''
}

import myHeader from '@/components/pageHEader/pageHeader'
import { dateFormat } from '@/utils'
import {
  getStores,
  addStores,
  delStores,
  modStores,
  getStoreInfo,
  getStoreCountries,
  disableOrEnableStore
} from '@/api/baseconfig/store'
import { getProvinces, getCities, getCoungries } from '@/api/common'

export default {
  name: 'parcel',
  components: {
    myHeader
  },
  data() {
    return {
      pageSize: 20,
      currentPage: 1,
      total: 0,
      data: [],
      //表格选中
      multipleSelection: [],
      treeData: [],
      //搜索
      search: this.cloneObj(search),
      //选中国家
      selectCountry: '',
      activeName: 'storeBaseForm',
      //对话框
      dialogFormVisible: false,
      title: '添加',
      storeBaseForm: this.cloneObj(storeBaseForm),
      storeDetailForm: this.cloneObj(storeDetailForm),
      waybillForm: this.cloneObj(waybillForm),
      storeBaseRules: {
        //门店名称
        name: [this.$RegExp.required()],
        //门店编码
        code: [this.$RegExp.required()],
        //出店周期
        outCycle: [this.$RegExp.required('出店周期选中不能为空')]
      },
      storeDetailRules: {
        //国家名称
        countryName: [this.$RegExp.required('国家名称不能为空')],
        //省份
        provinceName: [this.$RegExp.required('省份名称不能为空')],
        //城市名称
        cityName: [this.$RegExp.required('城市名称不能为空')],
        //县
        countyName: '',
        //街道
        streetName: '',
        //邮政编码
        postalCode: '',
        //详细地址
        address: '',
        //电话
        phoneNum: '',
        //手机
        mobilePhoneNum: '',
        //传真
        faxNum: '',
        //电子邮件
        email: ''
      },
      storeBaseOptions:{
        currencyType:[],
        currencySymbol:[],
        weightUnit:[],
      },
      storeDetailOptions: {
        countryName: [],
        provinceName: [],
        cityName: [],
        countyName: [],
        streetName: []
      },
      waybillInfos: [],
      //查看门店
      dialogViewVisible: false
    }
  },
  created() {
    //获取字典信息
    this.getDic('Currency').then(resp=>{
      this.storeBaseOptions.currencyType = resp.data.records[0].childrenInfo
    })
    this.getDic('Weight').then(resp=>{
      this.storeBaseOptions.weightUnit = resp.data.records[0].childrenInfo
    })
    this.getDic('CurrencySymbol').then(resp=>{
      this.storeBaseOptions.currencySymbol = resp.data.records[0].childrenInfo
    })
  },
  mounted() {
    //获取所有国家
    getCoungries().then((resp) => {
      this.storeDetailOptions.countryName = resp.data
    })

    this.getStores()
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val
      this.getStores()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.getStores()
    },
    handleNodeClick(node) {
      this.selectCountry = node.label
      this.getStores()
    },
    //重置表单信息
    restForm() {
      this.$nextTick(() => {
        if (this.$refs.storeBaseForm) this.$refs.storeBaseForm.resetFields()
        if (this.$refs.storeDetailForm) {
          this.$refs.storeDetailForm.resetFields()
        }
      })
    },
    handleBeforeUpdate(){
      if (!this.multipleSelection.length) {
        this.tip();
        return;
      }
      if (this.multipleSelection.length > 1) {
        this.tip("只能勾选表格中的一条数据");
        return;
      }
      this.handleAddUpdate(this.multipleSelection[0])
    },
    handleAddUpdate(row) {
      this.activeName = 'storeBaseForm'
      //修改处理
      if (row) {
        //查询单条数据
        getStoreInfo(row.id).then((resp) => {
          let row = resp.data
          //将运单收费数据复制给数组
          this.waybillInfos = row.waybillInfos
          //将数据复制给form
          this.handleModform(row, this.storeBaseForm)
          this.handleModform(row, this.storeDetailForm)
          this.getProvinces()
          this.getCities()
          this.storeBaseForm.id = row.id
          this.dialogFormVisible = true
        })
        this.title = '修改'
      } else {
        this.waybillInfos = []
        this.storeDetailOptions.provinceName = []
        this.storeDetailOptions.cityName = []
        this.storeBaseForm = this.cloneObj(storeBaseForm)
        this.storeDetailForm = this.cloneObj(storeDetailForm)
        this.title = '添加'
        this.dialogFormVisible = true
      }
    },
    getStores() {
      let query = {
        pageNum: this.currentPage,
        pageSize: this.pageSize,
        enabled: this.search.Enabled,
        name: this.search.name,
        countryName: this.selectCountry
      }
      //获取门店所在的国家
      getStoreCountries().then((resp) => {
        this.treeData = resp.data.map((item) => ({ label: item, id: item }))
      })
      getStores(query).then((resp) => {
        this.data = resp.data.records
        this.total = resp.data.total
      })
    },
    //搜索
    searchPage(){
      this.currentPage = 1
      this.pageSize = 20
      this.getStores()
    },
    //表格双击修改
    handleRowDbclick(row) {
      this.handleAddUpdate(row)
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    //获取省份
    getProvinces() {
      getProvinces(this.storeDetailForm.countryName).then((resp) => {
        this.storeDetailOptions.provinceName = resp.data
      })
    },
    //获取市
    getCities() {
      getCities(this.storeDetailForm.provinceName).then((resp) => {
        this.storeDetailOptions.cityName = resp.data
      })
    },
    //select改变
    handleCountryChange() {
      this.storeDetailOptions.provinceName = []
      this.storeDetailForm.provinceName = ''
      this.getProvinces()
    },
    handleProvinceChange() {
      this.storeDetailOptions.cityName = []
      this.storeDetailForm.cityName = ''
      this.getCities()
    },
    submit() {
      this.$refs['storeBaseForm'].validate((valid) => {
        if (valid) {
          this.$refs['storeDetailForm'].validate((valid) => {
            if (valid) {
              let submit = Object.assign(
                { waybillInfos: this.waybillInfos },
                this.storeBaseForm,
                this.storeDetailForm
              )
              let request
              if (this.title == '添加') {
                request = addStores(submit)
              } else {
                request = modStores(submit)
              }
              request.then((resp) => {
                this.$message.success(resp.message || '成功')
                this.dialogFormVisible = false
                this.$store.dispatch('getStores')
                this.getStores()
              })
            } else {
              this.activeName = 'storeDetailForm'
            }
          })
        } else {
          this.activeName = 'storeBaseForm'
        }
      })
    },
    //查看门店信息
    storeView() {
      if (!this.multipleSelection.length) {
        this.tip()
        return
      }
      this.dialogViewVisible = true
    },
    //启用或禁用
    enabled(enabled) {
      if (!this.multipleSelection.length) {
        this.tip()
        return
      }
      let stores = this.multipleSelection.map((item) => item.id)
      let tip
      if (enabled) {
        tip = '此操作将启用门店, 是否继续?'
      } else {
        tip = '此操作将禁用门店, 是否继续?'
      }
      this.confirm(tip).then(() => {
        disableOrEnableStore(stores, { enabled }).then((resp) => {
          this.$message.success(resp.message || '成功')
          this.getStores()
        })
      })
    },
    //删除门店
    delStores() {
      if (!this.multipleSelection.length) {
        this.tip()
        return
      }
      this.confirm().then(() => {
        delStores(this.multipleSelection.map((item) => item.id)).then(
          (resp) => {
            this.$message.success(resp.message || '成功')
            this.getStores()
          }
        )
      })
    },
    //运单收费信息
    addwaybill() {
      this.waybillInfos.push(this.cloneObj(waybillForm))
    },
    deletewaybill(index) {
      this.confirm().then(() => {
        this.waybillInfos.splice(index, 1)
      })
    }
  }
}
</script>

<style scoped lang='scss'>

</style>
